# Apache Web Server Apache Web Server (Apache HTTP Server) is an open-source, cross-platform web server software developed and maintained by the Apache Software Foundation. It is renowned for its stability, security, and high scalability, supporting a wide range of features through its rich module ecosystem. It is one of the most widely used web servers globally, commonly employed for website hosting, dynamic application support, and reverse proxy scenarios. This document describes how to install and run the **Apache Web Server** on a Quectel Pi M1 / L1 Debian system, and access the web pages from a Windows computer on the same local network. # Prerequisites 1. Verify the device environment: - The Quectel Pi M1 / L1 and the Windows host are on the same local network and can communicate with each other - If you plan to install Apache online via `apt`, the device must also be able to access Debian software repositories 2. Check network connectivity: - Run `hostname -I` in the device terminal to view the current IP address, then `ping` the Windows host or gateway address on the same subnet. If you see round-trip time information returned, local network communication is working. You can also run `ping 10.66.84.17` on the M1/Windows host (use the actual device IP) to confirm. 3. Log in to the development board: - **M1**: Log in via serial port or graphical interface, using the default `q` user. - **L1: If the local debug environment is already available, you can also enter the system via ADB; this document uses serial port login as an example. For login methods, refer to debug_uart.md. L1 defaults to`root`****login with no system password.** # Install Apache Web Service Apache is one of the most commonly used web server programs for providing website access services. 1. Update the software repository: ```bash sudo apt update ``` 2. Install Apache service: ```bash sudo apt install apache2 -y ``` > 💡 If the current network cannot access Debian software repositories, you can first download the `apache2`, `apache2-data`, `apache2-utils`, and other architecture-specific installation packages on the host, then copy them to the device for offline installation. 3. Verify Apache installation success: ```bash /usr/sbin/apache2 -v ``` # Start and Set Auto-Start 1. Start Apache service: ```bash sudo systemctl start apache2 ``` 2. Set to start automatically on boot: ```bash sudo systemctl enable apache2 ``` 3. Check running status: ```bash sudo systemctl status apache2 systemctl is-active apache2 systemctl is-enabled apache2 ``` # Allow Web Access Port If the device firewall has restricted port `80`, you need to add an allow rule. The following example allows a specified Windows host to access the device's HTTP service (replace `` with the actual IP; the M1 test sample is 10.66.84.17): ```bash sudo iptables -I INPUT 1 -i eth0 -p tcp -s --dport 80 -j ACCEPT ``` View port listening and firewall rules: ```bash netstat -tulnp | grep ':80' sudo iptables -S INPUT | grep 80 ``` In testing, Apache was found to be listening on `0.0.0.0:80` or `:::80`. When accessing, use the device's current IP address obtained via `hostname -I`. # View Device IP Address ```bash hostname -I ``` # Test Apache Installation 1. In a browser on a computer on the same local network, visit: ``` http://<开发板IP>/ http://10.66.84.182/ ``` 2. If everything is working correctly, you should see the Apache default page. # Change the Default Web Page Apache's default web page is an HTML file in the filesystem, located at `/var/www/html/index.html`. Navigate to this directory and view its contents: ```bash cd /var/www/html ls -al ``` This will display the following: ``` total 20 drwxr-xr-x 2 root root 4096 Oct 30 07:53 . drwxr-xr-x 3 root root 4096 Oct 30 06:51 .. -rw-r--r-- 1 root root 10703 Oct 30 06:51 index.html ``` The system has a default web page file named `index.html` in the `/var/www/html` directory, owned by the `root` user. Since regular users cannot directly modify files owned by root, if you need to edit this web page, you must change its owner to your own username. - **M1 (default q user)**: ```bash sudo chown q:q index.html ``` - **L1 or other custom users**: ```bash sudo chown <用户名>:<用户名> index.html ``` Now you can edit this file. After making changes, simply refresh the browser to see the updated web page. # Troubleshooting | **Symptom** | **Possible Cause** | **Solution** | | --- | --- | --- | | Windows Command Prompt says `Test-NetConnection` is not recognized as an internal or external command | `Test-NetConnection` is a PowerShell command, not a CMD command | Open Windows PowerShell and re-run `Test-NetConnection -Port 80` | | Able to `ping` the device but browser cannot open the web page, and `TcpTestSucceeded` is `False` | Apache service is not running, port 80 is not listening, or the device firewall has not allowed port 80 | Run `sudo systemctl status apache2`, `sudo systemctl restart apache2`, `netstat -tulnp \| grep ':80'` in sequence on the device to verify service status and port listening | | `apt install apache2` cannot complete | The device's current network cannot access Debian software repositories | First verify the development board has external network access; if only the local network is available, download the `apache2`-related installation packages on the host and copy them to the development board for offline installation (see the notes in the installation section) | | IP address is correct but still cannot access | The device and Windows host are not on the same local network, or the IP address changed after switching ADB/Ethernet | Run `hostname -I` on the device to reconfirm the IP address, and ensure the Windows host and device are on the same subnet | If Apache is confirmed to be listening on `0.0.0.0:80` but Windows still cannot access it, you can temporarily allow the Windows host to access port 80 (replace `` with the actual IP): ```bash sudo iptables -I INPUT 1 -i eth0 -p tcp -s --dport 80 -j ACCEPT ```